<?php
/**
 * Created By base
 * Author: Virus
 * Date: 2020/3/11
 * Time: 19:06
 */

namespace app\admin\validate;


use think\Validate;

class Menu extends Validate
{
    protected $rule = [
        'id'      => 'require|number|integer',
        'name'    => 'require',
        'title'   => 'require',
        'status'  => 'require|number|integer',
        'pid'     => 'require|number|integer',
        'is_menu' => 'require|number|integer',
    ];

    protected $message = [
        'title.require'   => '标题必须',
        'status.require'  => '状态必须选',
        'status.number'   => '状态值为数字',
        'status.integer'  => '状态值必须为整型',
        'pid.require'     => '父级权限必须',
        'pid.number'      => '父级pid必须为数字',
        'pid.integer'     => '父级pid必须为整型',
        'is_menu.require' => '是否是菜单必须选',
        'is_menu.number'  => '是否是菜单值为数字',
        'is_menu.integer' => '是否是菜单值为整型',
        'id.require'      => 'id必须',
        'id.number'       => 'id必须为数字',
        'id.integer'      => 'id必须为整型',
    ];

    protected $scene = [
        'add'  => ['title', 'status', 'pid', 'is_menu'],
        'edit' => ['title', 'status', 'pid', 'is_menu', 'id'],
    ];

    //允许操作的方法
    public $allowAction = ['add', 'edit'];
    //禁止操作的方法
    public $forbidAction = ['index'];
}